package com.gxan.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.gxan.common.JsonResult;

import com.gxan.pojo.Resume;
import com.gxan.service.ResumeService;
import com.gxan.service.impl.ResumeServiceImpl;
import com.gxan.utils.DateUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/resume/queryResume")
public class QueryResumeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String page = request.getParameter("page");
        String limits = request.getParameter("limit");
        String name = request.getParameter("name");
        String job_title = request.getParameter("job_title");
        String work_experience = request.getParameter("work_experience");
        String recommend_the_interview = request.getParameter("recommend_the_interview");
        String registration_time = request.getParameter("registration_time");
        Resume resume = new Resume();
        resume.setName(name);
        resume.setJob_title(job_title);
        resume.setWork_experience(work_experience);
        resume.setRecommend_the_interview(recommend_the_interview);
        resume.setRegistration_time(DateUtils.string2Date(registration_time));
        //传递给service处理界面
        ResumeService recruitmentService = new ResumeServiceImpl();
        JsonResult jsonResult = recruitmentService.queryResumeList(Integer.valueOf(page), Integer.valueOf(limits), resume);
        //返回数据到前端
        response.setContentType("application/json;charset=utf-8");
//        response.setCharacterEncoding("utf-8");
        response.getWriter().write(JSONObject.toJSONString(jsonResult));
        response.getWriter().flush();
        response.getWriter().close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
